<?php
/**
 * Created by PhpStorm.
 * User: PanChaoZhi
 * Date: 2017/1/25
 * Time: 17:43
 */
/**
 * @var $msg frontend\controllers\ListController
 * @var $cate_group common\models\CategoryGroup
 * @var $id frontend\controllers\ListController
 * @var $groups common\models\CategoryGroup
 * @var $model common\models\Category
 */
$this->title = "揭示版一览";
$this->params['breadcrumbs'][] = $this->title;
use yii\bootstrap\Alert;
?>
<div class="main pd20">
    <h2>揭示板一览</h2>
    <?php if(!$msg):?>
        <?php
        Alert::begin([
            'options' => [
                'class' => 'alert-warning',
            ],
        ]);

        echo "你还没有关注板块,将不能发帖!注册用户只有在关注的板块中才能发帖!";

        Alert::end();

        ?>
    <?php endif ?>
    <div class="cate-group">
        <div class="row">

            <?php use common\Yii01;

            foreach ($cate_group as $v): ?>
                <div class="col-xs-2 ">
                    <a <?php if ($id == $v['id']): ?>class="select" <?php endif ?>
                       href="<?= Yii::$app->urlManager->createUrl(['list/index', 'id' => $v['id']]) ?>"><?= $v['name'] ?></a>
                </div>
            <?php endforeach ?>
        </div>

    </div>
    <p class="cate-title"><?= $groups['name'] ?>相关的板块</p>

    <div class="cate-main">
        <div class="row">

            <?php $n=0; foreach ($model as $v): ?>
                <?php $n++;?>
                <div class="col-xs-6 col-sm-6 col-xs-6 mb20">
                    <div style="border:1px #ccc solid; padding:5px;">
                        <div class="media">
                            <div class="media-left">
                                <a href="<?=Yii::$app->urlManager->createUrl(['post/index','cid'=>$v['id']])?>">
                                    <?php if ($v['logo']): ?>
                                        <img class="media-object" src="<?= Yii::$app->urlManager->baseUrl.'/'.$v['logo'] ?>" alt="<?= $v['name'] ?>"
                                             width="100px" height="100px">
                                    <?php else: ?>
                                        <img class="media-object" src="/img/default-logo.jpg" alt="<?= $v['name'] ?>"
                                             width="100px" height="100px">
                                    <?php endif ?>
                                </a>
                            </div>
                            <div class="media-body">
                                <h4 class="media-heading"><a href="<?=Yii::$app->urlManager->createUrl(['post/index','cid'=>$v['id']])?>"><?= $v['name'] ?></a></h4>

                                <div class="des">
                                    <p><?= Yii01::cutStr($v['description'],28) ?></p>
                                </div>
                                <?php if(Yii01::isDingyue($v['id'])):?>
                                    <div class="info">
                                        <button class="btn btn-danger fuckdy btn-xs dingyue" ><span>已订阅</span><i style="display: none"><?=$v['id']?></i></button>
                                        <b style="float: right">订阅:<span><?=$v['dynum']?></span></b>
                                        <b style="float: right">帖子:<span><?=Yii01::getCatePostNum($v['id'])?></span></b>
                                    </div>
                                <?php else :?>
                                    <div class="info">
                                        <button class="btn btn-success btn-xs dingyue" ><span>+ 订阅</span><i style="display: none"><?=$v['id']?></i></button>
                                        <b style="float: right">订阅:<span><?=$v['dynum']?></span></b>
                                        <b style="float: right">帖子:<span><?=Yii01::getCatePostNum($v['id'])?></span></b>
                                    </div>
                                <?php endif ?>
                            </div>
                        </div>
                    </div>
                </div>
                <?php if($n % 2 == 0):?>
                    <div class="clearfix"></div>
                <?php endif?>

            <?php endforeach ?>
        </div>
    </div>
</div>